package string;

/**
 * String支持的正则表达式方法二：
 * String replaceAll(String regex,String replacement)
 * 将当前字符串中满足正则表达式regex的部分替换为指定字符
 */
public class RepalceAllDemmo {
    public static void main(String[] args) {
        //将数字替换为#NUMBER#
        String line="123abc456def";
        line=line.replaceAll("[0-9]+","#NUMBER#");
        System.out.println(line);

        //和谐用语
        String resex="(gun|sb)";
        String message="sb,gun";
        message=message.replaceAll(resex,"***");
        System.out.println(message);
    }
}
